package com.yanqu.road.server.cmd.cookboy;

import com.yanqu.road.pb.cookboy.CookBoyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.cookboy.CookBoyMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_COOK_BOY_LEAVE, desc = "退出场景")
public class CookBoyLeaveCmd extends AbstractCommand {

	int activityId;
	long openBanquetUserId = 0;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		CookBoyProto.CookBoyLeaveReq reqMsg = CookBoyProto.CookBoyLeaveReq.parseFrom(packet.getBytes());
		activityId = reqMsg.getActivityId();
		openBanquetUserId = reqMsg.getOpenBanquetUserId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		CookBoyMgr.removeSceneUser(activityId,player.getUserId(),openBanquetUserId);
	}

	@Override
	public void sendData(GamePlayer player) {
		CookBoyProto.CookBoyTableRespMsg.Builder respMsg = CookBoyProto.CookBoyTableRespMsg.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_COOK_BOY_LEAVE, respMsg);
	}
}
